#include <bits/stdc++.h>
using namespace std;
string s;
namespace sub1{
    const int N = (1<<20)+1;
    int ans;
    bool vis[21][N];
    #define get(x) ((val>>x)&1)
    void dfs(int val,int len)
    {
        if(vis[len][val]) return;
        ans++,vis[len][val] = 1;
        if(len<2) return;
        for(int i = 0;i<len-1;i++)
            if(get(i)==get(i+1)||(get(i)==1&&get(i+1)==0))
            {
                int tmp = 0,cnt = 0;
                for(int j = 0;j<i;j++)
                {
                    if(get(j)) tmp|=(1<<cnt);
                    cnt++;
                }
                for(int j = i+2;j<len;j++)
                {
                    if(get(j)) tmp|=(1<<cnt);
                    cnt++;
                }
                dfs(tmp,cnt);
            }
    }
    inline void main()
    {
        int v = 0;
        for(int i = 0;i<s.size();i++)
            if(s[i]=='B') v+=(1<<i);
        dfs(v,s.size());
        cout<<ans;
    }
}
namespace sub2{
    inline void main()
    {
        if(s[0]=='A') cout<<(s.size()+1)/2;
        else cout<<s.size()/2+1;
    }
}
signed main()
{
    freopen("song.in","r",stdin);
    freopen("song.out","w",stdout);
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>s;
    if(s.size()<=20) sub1::main();
    else sub2::main();
    return 0;
}